package com.imufe.chemicalenterprisedangerwarning.controller;

import com.imufe.chemicalenterprisedangerwarning.entity.query.CreateGroup;
import com.imufe.chemicalenterprisedangerwarning.entity.query.UnitItemQuery;
import com.imufe.chemicalenterprisedangerwarning.entity.vo.UnitItemDetailedVO;
import com.imufe.chemicalenterprisedangerwarning.exception.ValidationException;
import com.imufe.chemicalenterprisedangerwarning.service.UnitItemService;
import com.imufe.chemicalenterprisedangerwarning.common.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 模块条目表 前端控制器
 * </p>
 *
 * @author BaiBan
 * @since 2022-10-06
 */
@Api(tags = "检查模块")
@RestController
@RequestMapping("/unit-item")
public class UnitItemController {

    @Autowired
    UnitItemService service;

    @ApiOperation(value = "新增", notes = "新增一个模块条目项，返回新增的模块条目项")
    @PostMapping("/create")
    public ResponseEntity<UnitItemDetailedVO> create(@RequestBody @Validated(CreateGroup.class) UnitItemQuery query) throws ValidationException {
        UnitItemDetailedVO detailedVO = service.create(query);
        return ResponseEntity.success(detailedVO);
    }
}